//
//  RealUserViewController.m
//  Jyxt
//
//  Created by 宫璞 on 2017/9/11.
//  Copyright © 2017年 DaLian Rental Housing Management. All rights reserved.
//

#import "RealUserViewController.h"
#import "RealUserTableViewCell.h"
#import "ScontractDetailViewModel.h"
#import "UserCenterViewModel.h"

@interface RealUserViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *realUserTableview;
@property (nonatomic, strong) NSMutableArray *realUserArr;


@end

@implementation RealUserViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self createNet];
}

- (void)initView{
    self.title = @"实际使用人";
    self.view.backgroundColor = [UIColor whiteColor];
    self.realUserTableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 44, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width - 44) style:UITableViewStylePlain];
    self.realUserTableview.delegate = self;
    self.realUserTableview.dataSource = self;
    self.realUserTableview.tableFooterView = [[UIView alloc]init];
    [self addSubview: self.realUserTableview];
}

- (void)createNet{
    [[ScontractDetailViewModel sharedInstance] requestContractDetailWithUtoken:[UserCenterViewModel getLocalUToken] id:self.contractId success:^(NSArray *array) {
        self.realUserArr = [NSMutableArray new];
        [self.realUserArr addObjectsFromArray:array];
        [self.realUserTableview reloadData];
    } Fail:^(NSError *error) {
        
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.realUserArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44 *3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *indentity = @"indentity";
    NSString *indentity1 = @"indentity1";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentity];
    if (cell == nil) {
        cell = [[RealUserTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentity1];
    }
    
    McontractDetailModel *model = [self.realUserArr objectAtIndex:0];
    [((RealUserTableViewCell *) cell) setContent:model];
    return cell;
}

@end
